Imports System.Data.SqlClient
Partial Class Secure_Pages_CMS
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Dim con As SqlConnection
            Dim cmd As SqlCommand
            Dim rdr As SqlDataReader

            Dim urlVar As String = Nothing
            Dim titleVar As String = Nothing
            Dim pageidVar As Integer = Nothing
            Dim pageSubtitleVar As String = Nothing
            Dim pageDescriptionVar As String = Nothing

            con = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("sqlConn"))
            cmd = New SqlCommand("select * from pages where CMSPage = 1", con)
            con.Open()
            rdr = cmd.ExecuteReader()
            While rdr.Read
                If rdr("url") = "index.aspx" Then
                    pageidVar = rdr(ID)
                End If
                pageNavigationLabel.Text &= "<li><a href=" & rdr("url") & ">" & rdr("title") & "</a></li>"
            End While
            rdr.Close()
            con.Close()
        End If
    End Sub


    'Dim i As Integer
    'i = 0
    'Dim comArray(Ds1.OT_SHIFT.Rows.Count) As String

    'For Each r As DataRow In Ds1.Tables("OT_Shift").Rows
    '    comArray(i) = r.Item(9)
    '    If comArray(i).Length > 15 Then
    '        comArray(i) = comArray(i).Substring(0, 10)
    '        r.Item(9) = comArray(i) & "..."
    '    End If
    '    i = i + 1
    'Next

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim strConnection As String = System.Configuration.ConfigurationManager.AppSettings("sqlConn")
        Dim objConnection As New SqlConnection(strConnection)
        Dim UpdateStr As String = "INSERT INTO pages (url, image_id, title, description, subtitle, CMSPage, Active) VALUES ('" & txburl.Text & "', '" & ImageId.Text & "', '" & txbTitle.Text & "', '" & Description.Text & "', '" & Subtitle.Text & "', '" & IsCMS.Checked & "', '" & IsActive.Checked & "')"
        Dim dbCommand As New SqlCommand(UpdateStr, objConnection)
        objConnection.Open()
        dbCommand.ExecuteNonQuery()
        objConnection.Close()
        Label1.ForeColor = Drawing.Color.Black
    End Sub
End Class
